﻿using AutoMapper;
using Coldairarrow.Business.Wms;
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Entity.Wms;
using Coldairarrow.Util;
using EFCore.Sharding;
using LinqKit;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Coldairarrow.Business.Base_Manage
{
    public class Wms_WarehouseBusiness : BaseBusiness<wms_Warehouse>, IWms_WarehouseBusiness, ITransientDependency
    {
        readonly IMapper _mapper;
        public Wms_WarehouseBusiness(IRepository repository, IMapper mapper)
            : base(repository)
        {
            _mapper = mapper;
        }

        #region 外部接口

        public async Task<PageResult<wms_Warehouse>> GetDataListAsync(PageInput<wms_Warehouse> input)
        {
            var q = GetIQueryable();
            var where = LinqHelper.True<wms_Warehouse>();
            var search = input.Search;
            if (!search.Name.IsNullOrEmpty())
            {
                where = where.And(x =>
                    x.Id.Contains(search.Id)
                    || x.Code.Contains(search.Code)
                    || x.Name.Contains(search.Name));
            }

            return await q.Where(where).GetPageResultAsync(input);
        }

        public async Task<wms_Warehouse> GetTheDataAsync(string id)
        {
            return await GetEntityAsync(id);
        }

        public async Task AddDataAsync(wms_Warehouse newData)
        {
            await InsertAsync(newData);
        }

        public async Task UpdateDataAsync(wms_Warehouse theData)
        {
            await UpdateAsync(theData);
        }

        public async Task DeleteDataAsync(List<string> ids)
        {
            await DeleteAsync(ids);
        }

        #endregion

        #region 私有成员

        #endregion

        #region 数据模型

        #endregion
    }
}